Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number Game Errors: Move script inside body tag #775

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

MaoShizhong
Copy link
Contributor

@MaoShizhong MaoShizhong commented Oct 28, 2024

Because

In the "What went wrong?" exercise, there is a warning about line numbers in error messages potentially not matching source code line numbers due to code injection from extensions like live-server.

This is a result of the code's script tag being placed after the closing body tag, so live-server's injected code comes before it.

By placing the script tag before the closing body tag, live-server injects code after it, preserving line numbers in the error messages, making the lesson much easier to follow for more people. The relevant warning can then be removed from the lesson.

This has been tested with VSCode's Live Server extension, VSCode's Live Preview extension and the live-server npm package.

This PR

  • Moves the closing body tag down after the script tag closes.
  • Fixes inconsistent indentation across the file to only use 2 spaces per level (rather than mixing spaces and tabs).
  • Uses appropriate indentation for each block as necessary.

Additional information

This PR depends on (mdn/content#36541) which amends the line number references and screenshots in the lesson itself to match what these code changes will produce.

Was mixing tabs and spaces - now all indent via spaces and following a
consistent indent structure.
Allows servers to inject code after learning code and not before. Helps maintain line numbers for error messages.
Copy link
Contributor

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 yes, works for me with VSCode as well (and removes an error from the W3C validator).

@wbamberg wbamberg merged commit f262a5a into mdn:main Oct 30, 2024
@MaoShizhong MaoShizhong deleted the troubleshooting-move-script branch October 30, 2024 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants